//二维树状数组 - 区间修改 + 单点查询
#include <iostream>
using namespace std;
#define lowbit(x) (x & -x) 
int n, m;
const int N = 4100;
typedef long long ll;
ll s[N][N];

void modify(int x, int y, ll k)
{
    for(int i = x; i <= n; i += lowbit(i))
        for(int j = y; j <= m; j += lowbit(j))
            s[i][j] += k;
}

ll query(int x, int y)
{
    ll sum = 0;
    for(int i = x; i; i -= lowbit(i))
        for(int j = y; j; j -= lowbit(j))
            sum += s[i][j];
    return sum;
}


int main()
{
    cin >> n >> m;
    int op, a, b;
    while(cin >> op >> a >> b)
    {
        if(op == 1)
        {
            int c, d; ll k;
            cin >> c >> d >> k;
            //[a, b] -> [c, d] + k
            modify(a, b, k); 
            modify(a, d + 1, -k);
            modify(c + 1, b, -k);
            modify(c + 1, d + 1, k);
        }
        else
        {
            cout << query(a, b) << endl; 
        }
    }
    return 0;
}
